#!/usr/bin/env python
# -*- coding: UTF-8 -*-
'''
@Project ：hiflyworks_web_tests
@File    ：conftest.py.py
@Author  ：beibei
@Date    ：2025/6/20 4:59 PM
'''

from py.xml import html
import pytest

# ✅ 1. 在每个测试执行后，将 request.node.extra 写入 report.extra
@pytest.hookimpl(hookwrapper=True)
def pytest_runtest_makereport(item, call):
    outcome = yield
    report = outcome.get_result()
    # 将测试用例中的 extra 附加到报告
    extra = getattr(item, "extra", [])
    if extra:
        setattr(report, "extra", extra)


# ✅ 2. 用 pytest-html 官方推荐的方式插图：插入 extra 附件列
# def pytest_html_results_table_extra(report):
#     return getattr(report, "extra", [])


